package com.example.demo.config;

/**
 * Description:
 * User: 故我
 * Date: 2023-11-08
 * Time: 20:57
 */

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截器的实现
 */
@Configuration
public class ApplicationAdvice implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")//拦截所有页面以及数据
                .excludePathPatterns("/css/**") //以下的页面不进行拦截
                .excludePathPatterns("/editor.md/**")
                .excludePathPatterns("/imag/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/blog_detail.html")
                .excludePathPatterns("/blog_all_list.html")
                .excludePathPatterns("/blog_login.html")
                .excludePathPatterns("/blog_register.html")
                .excludePathPatterns("/user/login") //路由不能拦截
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/getuserbyid")
                .excludePathPatterns("/art/editlikecount")
                .excludePathPatterns("/art/getartbypage")
                .excludePathPatterns("/art/detail")
                .excludePathPatterns("/com/allcom")
                .excludePathPatterns("/art/liketreadcount")
                .excludePathPatterns("/art/edittreadcount")
                .excludePathPatterns("/com/addcom");
    }
}
